package com.chiancloud.shield.common.params;

import com.beust.jcommander.converters.BaseConverter;

import java.net.URI;
import java.net.URISyntaxException;

public class URIArgumentConverter extends BaseConverter<URI> {

  public URIArgumentConverter(String optionName) {
    super(optionName);
  }

  @Override
  public URI convert(String value) {
    try {
      return new URI(value);
    } catch (URISyntaxException e) {
      throw new RuntimeException("Cannot make a URI from " + value);
    }
  }
}
